package com.surprise.db.dao;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.google.common.collect.Maps;
import com.surprise.db.po.Category;

/**
 * CategoryDAO.java
 * @author nick
 * @since 2015年7月21日
 */
@Repository
public class CategoryDAO extends SimpleDAO<Category>{
	public Map<Integer, Category> getMapByType(int type) {
		String sql = "select * from #table# where type = ?";
		List<Category> list = super.findBySql(sql, type);
		Map<Integer, Category> map = Maps.newHashMap();
		for (Category cat : list) {
			map.put(cat.getSequence(), cat);
		}
		return map;
	}
	
	public List<Category> getListByType(int type) {
		String sql = "select * from #table# where type = ? order by sequence";
		List<Category> list = super.findBySql(sql, type);
		return list;
	}
}
